CSharpTest.Net
GetEnumerator Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration) 
Public Function GetEnumerator() As IEnumerator(Of T)
C# 
public IEnumerator<T> GetEnumerator()

Exceptions

ExceptionDescription
System.InvalidOperationExceptionGetEnumerator() may only be called once.
System.IO.InvalidDataExceptionEnumeration is out of sequence.
System.ArgumentExceptionDuplicate item in enumeration.

Example

Library/Library.Test/TestOrderedEnumeration.cs

C#Copy Code
var ordered = new OrderedEnumeration<byte>(new byte[0]);
using (var e = ordered.GetEnumerator())
    Assert.IsFalse(e.MoveNext());

try
{
    ((System.Collections.IEnumerable) ordered).GetEnumerator();
    Assert.Fail();
}
catch (InvalidOperationException) { }
VB.NETCopy Code
Dim ordered As var = New OrderedEnumeration(Of Byte)(New Byte(0) {})
Using e As var = ordered.GetEnumerator()
    Assert.IsFalse(e.MoveNext())
End Using

Try
    (DirectCast(ordered, System.Collections.IEnumerable)).GetEnumerator()
    Assert.Fail()
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys